<?php
require_once "wp-config.php";
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME);
mysql_query("SET NAMES utf8"); //connect in decode utf8
//$table_prefix
$w = $_GET['w'];
$e = $_GET['e'].'';
$e=substr($e,1,-1);

$sql = "select post_id from wp_postmeta where meta_key = 'geocraft_website' and meta_value like '%$w%'";
//echo $sql."<br/>";
$result=mysql_query($sql);
$sql = "update wp_postmeta set meta_value='$e' where meta_key='geocraft_meta_email' and meta_value='' and post_id=#id";
//echo $sql."<br/>";
if ($result) {
	while ($data=mysql_fetch_array($result)) {
		$sql2=str_replace("#id",$data['post_id'],$sql);
		//echo $sql2."<br/>";
		$ret = mysql_query($sql2);
		$sql2="update wp_posts set post_status='publish',post_type='listing' where ID=".$data['post_id'];
		$ret = mysql_query($sql2);
echo $sql2."<br/>";
	}
	//$sql = "update wp_posts set post_status='publish' where ID='geocraft_meta_email' and meta_value='' and post_id=#id";
}
echo "OK";
?>